define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'gamefps/index' + location.search,
                    add_url: 'gamefps/add',
                    edit_url: 'gamefps/edit',
                    del_url: 'gamefps/del',
                    multi_url: 'gamefps/multi',
                    import_url: 'gamefps/import',
                    table: 'gamefps',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'game.name', title: __('游戏名称'), operate: 'LIKE'},
                        {field: 'game.image', title: __('游戏logo'), events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
                        {field: 'cpu.name', title: __('cpu名称'), operate: 'LIKE'},
                        {field: 'graphics.name', title: __('显卡名称'), operate: 'LIKE'},
                        //{field: 'game_id', title: __('Game_id')},
                        {field: 'type', title: __('Type'),formatter: Table.api.formatter.status, searchList: {0: __('1k'), 1: __('2k'), 2: __('4k')}},
                        {field: 'fps', title: __('Fps')},
                        {field: 'min_fps', title: __('Min_fps')},
                        {field: 'max_fps', title: __('Max_fps')},
                        {field: 'dram_size', title: __('Dram_size')},
                        {field: 'gpu_mem_size', title: __('Gpu_mem_size')},
                        //{field: 'cpu_id', title: __('Cpu_id')},
                        //{field: 'xianka_id', title: __('Xianka_id')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
